package com.yongbao.controller.wechat;

import com.yongbao.common.WebResponse;
import com.yongbao.common.annotation.WebAccess;
import com.yongbao.common.utils.AssertUtil;
import com.yongbao.model.request.DishOrderDishRequest;
import com.yongbao.model.vo.DishOrderDishVO;
import com.yongbao.model.vo.DishVO;
import com.yongbao.service.DishOrderDishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhanghong
 */
@RestController
@RequestMapping("/wechat/dishOrderDish")
@Api(value = "【小程序】订单菜品模块", tags = {"【小程序】订单菜品模块"})
public class WechatDishOrderDishController {

    @Autowired
    private DishOrderDishService dishOrderDishService;
    @WebAccess(login = true)
    @ApiOperation(value = "根据订单id查询订单菜品", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/getByOrderId")
    public WebResponse<List<DishVO>> getByOrderId(@RequestBody DishOrderDishRequest request) {
        AssertUtil.assertNotNull(request.getOrderId(), "订单id不能为空");
        return WebResponse.build(dishOrderDishService.listQuery(request));
    }

}
